$(function(){
	$('.delete_bt').click(function(){del(this);});
	
	$('.add_bt').click(function(){add(this);});
});


function add(btn){
	
		var curBtn=$(btn);
		var selectedFuncId=$(".funcId_cl",$(btn).parent().parent()).text();
		/*alert(transDataId);*/
		$.post("/RobotWeb/selfservice/OrderFunctionAction.action",{funcId:selectedFuncId}
		,function(data){
			$(curBtn).attr("class","delete_bt");
			$(curBtn).attr("value","delete");
			$(curBtn).click(function(){del(this);});
		});
}

function del(btn){
		var curBtn=$(btn);
		var selectedFuncId=$(".funcId_cl",$(curBtn).parent().parent()).text();
		
		$.post("/RobotWeb/selfservice/UnOrderFunctionAction.action",{funcId:selectedFuncId}
		,function(data){
			$(curBtn).attr("class","add_bt");
			$(curBtn).attr("value","add");
			$(curBtn).click(function(){add(this);});
		});
}

/*$('#add').click(function(){
	
	var $options = $('#allFunctions option:selected');
	var $remove=$options.remove();
	$remove.appendTo('#selectedFunctions');
});

$('#add_all').click(function(){
	
	var $options = $('#allFunctions option');
	var $remove=$options.remove();
	$remove.appendTo('#selectedFunctions');
});

$('#allFunctions').dblclick(function(){
	
	var $options = $("option:selected",this);
	var $remove=$options.remove();
	$remove.appendTo('#selectedFunctions');
});


$('#remove').click(function(){
	
	var $options = $('#selectedFunctions option:selected');
	var $remove=$options.remove();
	$remove.appendTo('#allFunctions');
});

$('#remove_all').click(function(){
	
	var $options = $('#selectedFunctions option');
	var $remove=$options.remove();
	$remove.appendTo('#allFunctions');
});

$('#selectedFunctions').dblclick(function(){
	
	var $options = $("option:selected",this);
	var $remove=$options.remove();
	$remove.appendTo('#allFunctions');
});*/